package jjn.round2;

import java.util.Objects;

/**
 * @author Jjn
 * @since 2023/6/30 10:28
 */
public class LeetCode2490 {
    public boolean isCircularSentence(String sentence) {
        String[] parts = sentence.split(" ");
        if (parts.length == 0) {
            return true;
        }
        for (int i = 0; i < parts.length; i++) {
            String part = parts[i];
            String second = parts[(i + 1) % parts.length];
            if (!Objects.equals(part.charAt(part.length() - 1), second.charAt(0))) {
                return false;
            }
        }
        return true;
    }
    
    public static void main(String[] args) {
        String sentence = "LeetCode else ettl";
        boolean circularSentence = new LeetCode2490().isCircularSentence(sentence);
        System.out.println("circularSentence = " + circularSentence);
    }
}
